<template>
    <h3>内联事件处理器</h3>
    <button v-on:click="count++">加1</button>
    <p>{{count}}</p>

    <h3>方法事件处理器</h3>
    <button @click="add">加2</button>
    <p>{{num}}</p>

    <h3>传递参数</h3>
    <button @click="getmsg('信息')">传递msg</button>
    <!-- 实例 传参的过程中获取event-->
    <p @click="printname(item,$event)" v-for="(item,index) in names" :key="index">{{item}}</p>
</template>
<script>
    export default{
        data(){
            return{
                count:0,
                num:0,
                names:['123','456','789']
            }
        },
        methods:{
            //e是Event对象，就是原生js的Event对象
            add(e){
                console.log(e);
                console.log(e.target);
                this.num+=2
            },
            getmsg(msg){
                console.log(msg)

            },
            printname(msg,e){
                console.log(msg)
                console.log(e);

            }

        }

    }
</script>